﻿<sap:ActivityDesigner x:Class="Microsoft.Samples.SqlServer.Activities.Designers.ActivityPublishers.TablePartPublisherDesigner"
xmlns:s="clr-namespace:System;assembly=mscorlib"                      
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
    xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation" Collapsible="True">

    <sap:ActivityDesigner.Resources>
        <sapc:ArgumentToExpressionConverter 
                x:Key="ArgumentToExpressionConverter" />

        <DataTemplate x:Key="ShowAsCollapsed">
            <TextBlock Foreground="Gray">
                <TextBlock.Text>
                    <MultiBinding StringFormat="Style as {0}">
                        <Binding Path="ModelItem.StyleName" />
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </DataTemplate>

        <DataTemplate x:Key="ShowAsExpanded">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="52"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                    
                <TextBlock Text="Style" Margin="0,4,0,0" Grid.Row ="0" Grid.Column="0"></TextBlock>
                <ComboBox x:Name="nameCombobox" Grid.Row ="0" Grid.Column="1" Text="{Binding Path=ModelItem.StyleName}" Height="22" VerticalAlignment="Bottom" IsEditable="True" DropDownOpened="nameCombobox_DropDownOpened"/>

                <TextBlock Text="Resource" Margin="0,4,0,0" Grid.Row ="1" Grid.Column="0"></TextBlock>
                <ComboBox x:Name="resourceCombobox"  Margin="0,2,0,0" Grid.Row ="1" Grid.Column="1"  Text="{Binding Path=ModelItem.Resource}" Height="22" VerticalAlignment="Bottom" IsEditable="True" DropDownOpened="resourceCombobox_DropDownOpened" />

            </Grid>
        </DataTemplate>

        <Style x:Key="StyleWithCollapse" TargetType="{x:Type ContentPresenter}">
            <Setter Property="ContentTemplate" 
                Value="{DynamicResource ShowAsExpanded}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=ShowExpanded}" Value="False">
                    <Setter Property="ContentTemplate" 
                        Value="{DynamicResource ShowAsCollapsed }"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </sap:ActivityDesigner.Resources>

    <sap:ActivityDesigner.Icon>
        <DrawingBrush>
            <DrawingBrush.Drawing>
                <ImageDrawing>
                    <ImageDrawing.Rect>
                        <Rect Location="0,0"  Size="16,16" />
                    </ImageDrawing.Rect>
                    <ImageDrawing.ImageSource>
                        <BitmapImage UriSource="TablePartPublisher.png"/>
                    </ImageDrawing.ImageSource>
                </ImageDrawing>
            </DrawingBrush.Drawing>
        </DrawingBrush>
    </sap:ActivityDesigner.Icon>

    <Grid>
        <ContentPresenter Style="{DynamicResource StyleWithCollapse}" 
            Content="{Binding}" />
    </Grid>

</sap:ActivityDesigner>

